USE [PeDALS_DEV]
GO
/****** Object:  StoredProcedure [dbo].[PAC_UpdateProvenance]    Script Date: 02/23/2010 13:38:57 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[PAC_UpdateProvenance]
	@ProvenanceId INT,
	@ProvenanceName VARCHAR (100),
	@ProvenanceAdministrativeHistory VARCHAR (MAX),
	@ProvenanceGeneralNote VARCHAR (MAX)

AS
BEGIN
	TRY
	SET NOCOUNT ON
	BEGIN TRANSACTION
		UPDATE [PeDALS_DEV].[dbo].[Provenance]
		SET [PeDALS_DEV].[dbo].[Provenance].[ProvenanceName] = LTRIM(RTRIM(@ProvenanceName)),
			[PeDALS_DEV].[dbo].[Provenance].[ProvenanceAdministrativeHistory] = @ProvenanceAdministrativeHistory,
			[PeDALS_DEV].[dbo].[Provenance].[ProvenanceGeneralNote] = @ProvenanceGeneralNote,
			[PeDALS_DEV].[dbo].[Provenance].[ModifiedDate] = GetDate(),
			[PeDALS_DEV].[dbo].[Provenance].[ModifiedBy] = 'Cataloger'
	WHERE [PeDALS_DEV].[dbo].[Provenance].[ProvenanceId] = @ProvenanceId	
	COMMIT TRANSACTION
END TRY
BEGIN CATCH
      ROLLBACK TRANSACTION
		PRINT 'An error occurred.  Please notify your administrator to check the error database.'
		INSERT INTO [PEDALS_PAC_ERRORS].[dbo].[PAC_ERROR](ErrorNumber, ErrorMessage, CreatedDate)
			VALUES (ERROR_NUMBER(), ERROR_MESSAGE(), GETDATE())
END CATCH